import store from "../store"
import { useState, useEffect } from "react"
import { connect } from "react-redux"
function Third(props) {
    console.log(props);
    function deleteGoods(goods) {
        props.removeGoods(goods);
    }
    return (
        <div>
            <div>
                {
                    props.buyList.map((goods) => {
                        return <p key={goods.name}>
                            {goods.name}{goods.price}
                            <button onClick={deleteGoods.bind(this, goods)}>删除</button>
                        </p>
                    })
                }
            </div>
        </div >
    );

}
const mapStateToProps = (state) => {
    return {
        ...state
    }
}
const actionObj = {
    removeGoods(goods) {
        return {
            type: "removeGoods",
            goods: goods
        }
    }
}
export default connect(mapStateToProps, actionObj)(Third) 